home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / backgammon / bg.sty < prev    next >
Text File  |  1994-11-20  |  19KB  |  544 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %   bg.sty : A style file to annote backgammon matches and positions  %
  3. %                                      %
  4. %         Copyright by J. Richter 1994                          %
  5. %                                      %
  6. % Distribution and use is free, as long as you don't change this file %
  7. %                                      %
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9.  
  10. \newcount\@value
  11. \newcount\@f
  12. \newcount\@t
  13.  
  14. \newcount\@movenumber
  15. \newfont{\@bigboardfont}{bg scaled 750}
  16. \newfont{\@normalboardfont}{bg scaled 500}
  17. \newfont{\@smallboardfont}{bg scaled 250}
  18.  
  19. \newdimen\@whiteskip
  20. \@whiteskip=\textwidth
  21. \divide\@whiteskip by 2
  22.  
  23. \def\@black{-1}
  24. \def\@white{1}
  25. \def\@middle{0}
  26.  
  27. \newif\ifcube      % only true if the cubevalue should be printed with the boards
  28. \newif\ifblack     % only true if black is on move
  29. \newif\ifnumbers   % only true if boardpoints are numbered
  30. \newif\ifmoves     % only true if \move prints out his arguments
  31. \newif\ifindent    % only true if the moves of white are indented by \@whiteskip
  32. \newif\ifptsonmove % only true if points are numbered from the view of the one on move
  33. \newif\ifbothhalfs   % only true if both halfs of the board are printed
  34. \newif\ifsecmove     % only true if the move numbers change only every second move
  35.  
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. % Some global default settings of the switches %
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39.  
  40. \def\boardtype{drawnormalboard}
  41. \indenttrue
  42. \numberstrue
  43. \cubetrue
  44. \movestrue
  45. \blacktrue
  46. \ptsonmovetrue
  47. \bothhalfstrue
  48. \secmovetrue
  49.  
  50. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  51. % Macros to set and get the value of a point %
  52. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  53.  
  54. \def\@set[#1](#2){
  55.     \expandafter\xdef\csname point#1\endcsname{#2}}
  56.  
  57. \def\@get#1[#2]{
  58.     \edef#1{\csname point#2\endcsname}}
  59.  
  60. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  61. % Macro to make all points of the board empty %
  62. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  63.  
  64. \def\@clearboard{
  65. \@value=0{
  66. \loop \@set[\the\@value](0) \ifnum\@value<27\advance\@value by 1 \repeat}
  67. }
  68.  
  69. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  70. % Macro to set the board to the configuration at the start of the game %
  71. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  72.  
  73. % White plays from 0 to 24 with 0 being the bar of White
  74. % Black plays from 25 to 1 with 25 being the bar of Black
  75.  
  76. % a positive value means that White has this number of checkers on the point
  77. % a negative value means that Black has the negative of this number as 
  78. %                                          chechers on this point
  79.  
  80. \def\initboard{
  81. \@set[0](0) \@set[1](2) \@set[2](0) \@set[3](0) \@set[4](0) \@set[5](0) \@set[6](-5)
  82. \@set[7](0) \@set[8](-3) \@set[9](0) \@set[10](0) \@set[11](0) \@set[12](5)
  83. \@set[13](-5) \@set[14](0) \@set[15](0) \@set[16](0) \@set[17](3) \@set[18](0)
  84. \@set[19](5) \@set[20](0) \@set[21](0) \@set[22](0) \@set[23](0) \@set[24](-2)
  85. \@set[25](0)
  86. }
  87.  
  88. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  89. % Macros to draw a single point %
  90. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  91.  
  92. \def\@whitehangingpoint[#1]{
  93. \@get\@dummy[#1]
  94. \@value=\@dummy{
  95. \ifnum\@value=0\vbox{\hbox{k}\hbox{l}\hbox{m}\hbox{n}\hbox{o}}\else
  96. \ifnum\@value=1\vbox{\hbox{K}\hbox{l}\hbox{m}\hbox{n}\hbox{o}}\else
  97. \ifnum\@value=2\vbox{\hbox{K}\hbox{L}\hbox{m}\hbox{n}\hbox{o}}\else
  98. \ifnum\@value=3\vbox{\hbox{K}\hbox{L}\hbox{M}\hbox{n}\hbox{o}}\else
  99. \ifnum\@value=4\vbox{\hbox{K}\hbox{L}\hbox{M}\hbox{N}\hbox{o}}\else
  100. \ifnum\@value=5\vbox{\hbox{K}\hbox{L}\hbox{M}\hbox{N}\hbox{O}}\else
  101. \ifnum\@value>5\advance\@value by 166
  102. \vbox{\hbox{K}\hbox{L}\hbox{M}\hbox{N}\hbox{\char\the\@value}}\else
  103. \ifnum\@value=-1\vbox{\hbox{P}\hbox{l}\hbox{m}\hbox{n}\hbox{o}}\else
  104. \ifnum\@value=-2\vbox{\hbox{P}\hbox{Q}\hbox{m}\hbox{n}\hbox{o}}\else
  105. \ifnum\@value=-3\vbox{\hbox{P}\hbox{Q}\hbox{R}\hbox{n}\hbox{o}}\else
  106. \ifnum\@value=-4\vbox{\hbox{P}\hbox{Q}\hbox{R}\hbox{S}\hbox{o}}\else
  107. \ifnum\@value=-5\vbox{\hbox{P}\hbox{Q}\hbox{R}\hbox{S}\hbox{T}}\else
  108. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 176
  109. \vbox{\hbox{P}\hbox{Q}\hbox{R}\hbox{S}\hbox{\char\the\@value}}
  110. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  111. }
  112.  
  113. \def\@blackhangingpoint[#1]{
  114. \@get\@dummy[#1]
  115. \@value=\@dummy{
  116. \ifnum\@value=0\vbox{\hbox{p}\hbox{q}\hbox{r}\hbox{s}\hbox{t}}\else
  117. \ifnum\@value=1\vbox{\hbox{U}\hbox{q}\hbox{r}\hbox{s}\hbox{t}}\else
  118. \ifnum\@value=2\vbox{\hbox{U}\hbox{V}\hbox{r}\hbox{s}\hbox{t}}\else
  119. \ifnum\@value=3\vbox{\hbox{U}\hbox{V}\hbox{W}\hbox{s}\hbox{t}}\else
  120. \ifnum\@value=4\vbox{\hbox{U}\hbox{V}\hbox{W}\hbox{X}\hbox{t}}\else
  121. \ifnum\@value=5\vbox{\hbox{U}\hbox{V}\hbox{W}\hbox{X}\hbox{Y}}\else
  122. \ifnum\@value>5\advance\@value by 186
  123. \vbox{\hbox{U}\hbox{V}\hbox{W}\hbox{X}\hbox{\char\the\@value}}\else
  124. \ifnum\@value=-1\vbox{\hbox{u}\hbox{q}\hbox{r}\hbox{s}\hbox{t}}\else
  125. \ifnum\@value=-2\vbox{\hbox{u}\hbox{v}\hbox{r}\hbox{s}\hbox{t}}\else
  126. \ifnum\@value=-3\vbox{\hbox{u}\hbox{v}\hbox{w}\hbox{s}\hbox{t}}\else
  127. \ifnum\@value=-4\vbox{\hbox{u}\hbox{v}\hbox{w}\hbox{x}\hbox{t}}\else
  128. \ifnum\@value=-5\vbox{\hbox{u}\hbox{v}\hbox{w}\hbox{x}\hbox{y}}\else
  129. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 196
  130. \vbox{\hbox{u}\hbox{v}\hbox{w}\hbox{x}\hbox{\char\the\@value}}
  131. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  132. }
  133.  
  134. \def\@whitestandingpoint[#1]{
  135. \@get\@dummy[#1]
  136. \@value=\@dummy{
  137. \ifnum\@value=0\vbox{\hbox{e}\hbox{d}\hbox{c}\hbox{b}\hbox{a}}\else
  138. \ifnum\@value=1\vbox{\hbox{e}\hbox{d}\hbox{c}\hbox{b}\hbox{A}}\else
  139. \ifnum\@value=2\vbox{\hbox{e}\hbox{d}\hbox{c}\hbox{B}\hbox{A}}\else
  140. \ifnum\@value=3\vbox{\hbox{e}\hbox{d}\hbox{C}\hbox{B}\hbox{A}}\else
  141. \ifnum\@value=4\vbox{\hbox{e}\hbox{D}\hbox{C}\hbox{B}\hbox{A}}\else
  142. \ifnum\@value=5\vbox{\hbox{E}\hbox{D}\hbox{C}\hbox{B}\hbox{A}}\else
  143. \ifnum\@value>5\advance\@value by 206
  144. \vbox{\hbox{\char\the\@value}\hbox{D}\hbox{C}\hbox{B}\hbox{A}}\else
  145. \ifnum\@value=-1\vbox{\hbox{e}\hbox{d}\hbox{c}\hbox{b}\hbox{0}}\else
  146. \ifnum\@value=-2\vbox{\hbox{e}\hbox{d}\hbox{c}\hbox{1}\hbox{0}}\else
  147. \ifnum\@value=-3\vbox{\hbox{e}\hbox{d}\hbox{2}\hbox{1}\hbox{0}}\else
  148. \ifnum\@value=-4\vbox{\hbox{e}\hbox{3}\hbox{2}\hbox{1}\hbox{0}}\else
  149. \ifnum\@value=-5\vbox{\hbox{4}\hbox{3}\hbox{2}\hbox{1}\hbox{0}}\else
  150. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 216
  151. \vbox{\hbox{\char\the\@value}\hbox{3}\hbox{2}\hbox{1}\hbox{0}}
  152. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  153. }
  154.  
  155. \def\@blackstandingpoint[#1]{
  156. \@get\@dummy[#1]
  157. \@value=\@dummy{
  158. \ifnum\@value=0\vbox{\hbox{j}\hbox{i}\hbox{h}\hbox{g}\hbox{f}}\else
  159. \ifnum\@value=1\vbox{\hbox{j}\hbox{i}\hbox{h}\hbox{g}\hbox{F}}\else
  160. \ifnum\@value=2\vbox{\hbox{j}\hbox{i}\hbox{h}\hbox{G}\hbox{F}}\else
  161. \ifnum\@value=3\vbox{\hbox{j}\hbox{i}\hbox{H}\hbox{G}\hbox{F}}\else
  162. \ifnum\@value=4\vbox{\hbox{j}\hbox{I}\hbox{H}\hbox{G}\hbox{F}}\else
  163. \ifnum\@value=5\vbox{\hbox{J}\hbox{I}\hbox{H}\hbox{G}\hbox{F}}\else
  164. \ifnum\@value>5\advance\@value by 226
  165. \vbox{\hbox{\char\the\@value}\hbox{I}\hbox{H}\hbox{G}\hbox{F}}\else
  166. \ifnum\@value=-1\vbox{\hbox{j}\hbox{i}\hbox{h}\hbox{g}\hbox{5}}\else
  167. \ifnum\@value=-2\vbox{\hbox{j}\hbox{i}\hbox{h}\hbox{6}\hbox{5}}\else
  168. \ifnum\@value=-3\vbox{\hbox{j}\hbox{i}\hbox{7}\hbox{6}\hbox{5}}\else
  169. \ifnum\@value=-4\vbox{\hbox{j}\hbox{8}\hbox{7}\hbox{6}\hbox{5}}\else
  170. \ifnum\@value=-5\vbox{\hbox{9}\hbox{8}\hbox{7}\hbox{6}\hbox{5}}\else
  171. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 236
  172. \vbox{\hbox{\char\the\@value}\hbox{8}\hbox{7}\hbox{6}\hbox{5}}
  173. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  174. }
  175.  
  176. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  177. % Macro to draw the pieces on the bar %
  178. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  179.  
  180. \def\hangingbar[#1]{
  181. \@get\@dummy[#1]
  182. \@value=\@dummy{
  183. \ifnum\@value=0\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}\else
  184. \ifnum\@value=1\vbox{\hbox{*}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}\else
  185. \ifnum\@value=2\vbox{\hbox{*}\hbox{*}\hbox{z}\hbox{z}\hbox{z}}\else
  186. \ifnum\@value=3\vbox{\hbox{*}\hbox{*}\hbox{*}\hbox{z}\hbox{z}}\else
  187. \ifnum\@value=4\vbox{\hbox{*}\hbox{*}\hbox{*}\hbox{*}\hbox{z}}\else
  188. \ifnum\@value=5\vbox{\hbox{*}\hbox{*}\hbox{*}\hbox{*}\hbox{*}}\else
  189. \ifnum\@value>5\advance\@value by 146
  190. \vbox{\hbox{*}\hbox{*}\hbox{*}\hbox{*}\hbox{\char\the\@value}}\else
  191. \ifnum\@value=-1\vbox{\hbox{@}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}\else
  192. \ifnum\@value=-2\vbox{\hbox{@}\hbox{@}\hbox{z}\hbox{z}\hbox{z}}\else
  193. \ifnum\@value=-3\vbox{\hbox{@}\hbox{@}\hbox{@}\hbox{z}\hbox{z}}\else
  194. \ifnum\@value=-4\vbox{\hbox{@}\hbox{@}\hbox{@}\hbox{@}\hbox{z}}\else
  195. \ifnum\@value=-5\vbox{\hbox{@}\hbox{@}\hbox{@}\hbox{@}\hbox{@}}\else
  196. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 156
  197. \vbox{\hbox{@}\hbox{@}\hbox{@}\hbox{@}\hbox{\char\the\@value}}
  198. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  199. }
  200.  
  201. \def\standingbar[#1]{
  202. \@get\@dummy[#1]
  203. \@value=\@dummy{
  204. \ifnum\@value=0\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}\else
  205. \ifnum\@value=1\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{*}}\else
  206. \ifnum\@value=2\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{*}\hbox{*}}\else
  207. \ifnum\@value=3\vbox{\hbox{z}\hbox{z}\hbox{*}\hbox{*}\hbox{*}}\else
  208. \ifnum\@value=4\vbox{\hbox{z}\hbox{*}\hbox{*}\hbox{*}\hbox{*}}\else
  209. \ifnum\@value=5\vbox{\hbox{*}\hbox{*}\hbox{*}\hbox{*}\hbox{*}}\else
  210. \ifnum\@value>5\advance\@value by 146
  211. \vbox{\hbox{\char\the\@value}\hbox{*}\hbox{*}\hbox{*}\hbox{*}}\else
  212. \ifnum\@value=-1\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{@}}\else
  213. \ifnum\@value=-2\vbox{\hbox{z}\hbox{z}\hbox{z}\hbox{@}\hbox{@}}\else
  214. \ifnum\@value=-3\vbox{\hbox{z}\hbox{z}\hbox{@}\hbox{@}\hbox{@}}\else
  215. \ifnum\@value=-4\vbox{\hbox{z}\hbox{@}\hbox{@}\hbox{@}\hbox{@}}\else
  216. \ifnum\@value=-5\vbox{\hbox{@}\hbox{@}\hbox{@}\hbox{@}\hbox{@}}else
  217. \ifnum\@value<-5\multiply\@value by -1\advance\@value by 156
  218. \vbox{\hbox{\char\the\@value}\hbox{@}\hbox{@}\hbox{@}\hbox{@}}
  219. \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
  220. }
  221.  
  222. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  223. % Macros to draw some borders %
  224. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  225.  
  226. \def\@verticalborder{
  227. \@value=1\vbox{
  228. \loop \hbox{Z} \ifnum\@value<5\advance\@value by 1 \repeat}
  229. }
  230.  
  231. \def\@horizontalborder{
  232. \ifbothhalfs
  233. \@value=1\hbox{
  234. \loop \hbox{-} \ifnum\@value<13\advance\@value by 1 \repeat}
  235. \else
  236. \@value=1\hbox{
  237. \loop \hbox{-} \ifnum\@value<7\advance\@value by 1 \repeat}
  238. \fi
  239. }
  240.  
  241. \def\@middleoftheboard{
  242. \ifbothhalfs
  243. \hbox{  \vsize=0.5em
  244.     \hbox{Z}
  245.     \@value=1{
  246.     \loop \hbox{z} \ifnum\@value<6\advance\@value by 1 \repeat}
  247.     \hbox{ZzZ}
  248.     \@value=1{
  249.     \loop \hbox{z} \ifnum\@value<6\advance\@value by 1 \repeat}
  250.     \hbox{Z}
  251. }
  252. \else
  253. \hbox{  \vsize=0.5em
  254.     \hbox{Z}
  255.     \@value=1{
  256.     \loop \hbox{z} \ifnum\@value<6\advance\@value by 1 \repeat}
  257.     \hbox{ZzZ}
  258. }
  259. \fi
  260. }
  261.  
  262.     
  263. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  264. % Macros to write boards in various sizes %
  265. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  266.  
  267. \def\@onetotwelfe{\ifptsonmove
  268. \hbox{\char0\char128\char129\char130\char131\char132\char133\char0z\char0
  269. \ifbothhalfs
  270. \char134\char135\char136\char137\char138\char139\fi}
  271. \else
  272. \hbox{\char0\char151\char150\char149\char148\char147\char146\char0z\char0
  273. \ifbothhalfs
  274. \char145\char144\char143\char142\char141\char140
  275. \fi}
  276. \fi
  277. }
  278. \def\@twentyfourtothirteen{\ifptsonmove
  279. \hbox{\char0\char151\char150\char149\char148\char147\char146\char0z\char0
  280. \ifbothhalfs
  281. \char145\char144\char143\char142\char141\char140\fi}
  282. \else
  283. \hbox{\char0\char128\char129\char130\char131\char132\char133\char0z\char0
  284. \ifbothhalfs
  285. \char134\char135\char136\char137\char138\char139
  286. \fi}
  287. \fi
  288. }
  289.  
  290. \def\@drawcube{
  291. \ifcube\@value=\cubeowner\relax
  292. \ifnum\@value=\@black\@value=\@cubevalue
  293. \advance\@value by 127
  294. \vbox{\hbox to 1.5em{    \hfill
  295.             \vbox{    \hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}
  296.                 \hbox{z}\hbox{z}\hbox{z}\hbox{z}
  297.                 \hbox{-}\hbox{\hbox{Z}\char\the\@value\hbox{Z}}\hbox{-}
  298.                 \hbox{z}}
  299.             }
  300. }
  301. \else\ifnum\@value=\@white\@value=\@cubevalue
  302. \advance\@value by 127
  303. \vbox{\hbox to 1.5em{    \hfill
  304.             \vbox{    \hbox{z}
  305.                 \hbox{-}\hbox{\hbox{Z}\char\the\@value\hbox{Z}}\hbox{-}
  306.                 \hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}
  307.                 \hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}
  308.             }
  309. }
  310. \else\ifnum\@value=\@middle\@value=\@cubevalue
  311. \advance\@value by 127
  312. \vbox{\hbox to 1.5em{    \hfill
  313.             \vbox{    \hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}
  314.                 \hbox{-}\hbox{\hbox{Z}\char\the\@value\hbox{Z}}\hbox{-}
  315.                 \hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}\hbox{z}}
  316.             }
  317. }
  318. \fi\fi\fi\fi
  319. }
  320.  
  321. \def\@drawboard{
  322. \offinterlineskip
  323. \vbox{
  324.     \ifnumbers\ifblack\@twentyfourtothirteen\else\@onetotwelfe\fi\fi
  325.     \@horizontalborder
  326.     \hbox{  \@verticalborder
  327.         \@blackhangingpoint [24]
  328.         \@whitehangingpoint [23]
  329.         \@blackhangingpoint [22]
  330.         \@whitehangingpoint [21]
  331.         \@blackhangingpoint [20]
  332.         \@whitehangingpoint [19]
  333.         \@verticalborder
  334.         \hangingbar [0]
  335.         \@verticalborder
  336.         \ifbothhalfs
  337.         \@blackhangingpoint [18]
  338.         \@whitehangingpoint [17]
  339.         \@blackhangingpoint [16]
  340.         \@whitehangingpoint [15]
  341.         \@blackhangingpoint [14]
  342.         \@whitehangingpoint [13]
  343.         \@verticalborder
  344.         \fi
  345.     }
  346.     \@middleoftheboard
  347.     \hbox{  \@verticalborder
  348.         \@whitestandingpoint [1]
  349.         \@blackstandingpoint [2]
  350.         \@whitestandingpoint [3]
  351.         \@blackstandingpoint [4]
  352.         \@whitestandingpoint [5]
  353.         \@blackstandingpoint [6]
  354.         \@verticalborder
  355.         \standingbar [25]
  356.         \@verticalborder
  357.         \ifbothhalfs
  358.         \@whitestandingpoint [7]
  359.         \@blackstandingpoint [8]
  360.         \@whitestandingpoint [9]
  361.         \@blackstandingpoint [10]
  362.         \@whitestandingpoint [11]
  363.         \@blackstandingpoint [12]
  364.         \@verticalborder
  365.         \fi
  366.     }
  367.     \@horizontalborder
  368.     \ifnumbers\ifblack\@onetotwelfe\else\@twentyfourtothirteen\fi\fi
  369. }
  370. \@drawcube
  371. }
  372.  
  373. \def\@drawbigboard{
  374. {\@bigboardfont
  375. \@drawboard
  376. }
  377. }
  378.  
  379. \def\@drawnormalboard{
  380. {\@normalboardfont
  381. \@drawboard
  382. }
  383. }
  384.  
  385. \def\@drawsmallboard{
  386. {\@smallboardfont
  387. \@drawboard
  388. }
  389. }
  390.  
  391. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  392. % Macro to move a single checker %
  393. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  394.  
  395. \def\@movechecker(#1-#2){
  396. %
  397. \ifblack
  398. \xdef\from{#1}\xdef\to{#2}\xdef\@movecolour{\@black}\xdef\@negmovecolour{\@white}
  399. \else
  400. \@value=#1\multiply\@value by -1\advance\@value by 25\xdef\from{\the\@value}
  401. \@value=#2\multiply\@value by -1\advance\@value by 25\xdef\to{\the\@value}
  402. \xdef\@movecolour{\@white}\xdef\@negmovecolour{\@black}
  403. \fi
  404. %
  405. \@value=\@movecolour\multiply\@value by 25\advance\@value by 25\divide\@value by 2\relax
  406. \ifnum\@value=\to
  407. % bearoff %
  408. \@get\@dummy[\from]\@value=\@dummy\advance\@value by \@negmovecolour\@set[\from](\the\@value)
  409. \else\@get\@dummy[\to]\@value=\@dummy\multiply\@value by \@movecolour\relax
  410. \ifnum\@value=-1
  411. %A checker is hit%
  412. \gdef\washit{*}
  413. \@get\@dummy[\from]\@value=\@dummy\advance\@value by \@negmovecolour\@set[\from](\the\@value)
  414. \@set[\to](\@movecolour)
  415. \@value=\@movecolour\multiply\@value by 25\advance\@value by 25\divide\@value by 2\xdef\hit{\the\@value}
  416. \@get\@dummy[\hit]\@value=\@dummy\advance\@value by \@negmovecolour\@set[\hit](\the\@value)
  417. \else
  418. %normal move%
  419. \@get\@dummy[\from]\@value=\@dummy\advance\@value by \@negmovecolour\@set[\from](\the\@value)
  420. \@get\@dummy[\to]\@value=\@dummy\advance\@value by \@movecolour\@set[\to](\the\@value)
  421. \fi\fi
  422. }
  423.  
  424. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  425. % Macro to perform all moves contained in a string which    %
  426. % starts with a , and ends with 69-69,69-69.                %
  427. % defines \stringofmoves, which contains the formatted move %
  428. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  429.  
  430. \def\@moveallcheckers#1-#2,#3.{
  431. \@value=#1
  432. \ifnum\@value=69 %reached end of the list%
  433. \else\@f=#1\@t=#2%Delete blanks in #1 and #2 %
  434. \gdef\washit{}\@movechecker(\the\@f-\the\@t)
  435. \xdef\@dummy{\stringofmoves}
  436. \ifnum\@f=25\def\from{bar}\else\def\from{\the\@f}\fi
  437. \ifnum\@t=0\def\to{off}\else\def\to{\the\@t}\fi
  438. \edef\stringofmoves{\@dummy\comma\from--\to\washit}\gdef\comma{, }
  439. \expandafter\@moveallcheckers#3.\fi
  440. }
  441.  
  442. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  443. % Commands for the position and the game environment %
  444. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  445.  
  446. \newcommand{\blackpoint}[2]{\@value=#1\@set[\the\@value](-#2)}
  447. \newcommand{\whitepoint}[2]{\@value=#1\advance\@value by -25
  448.                 \multiply\@value by -1
  449.                 \@set[\the\@value](#2)}
  450. \newcommand{\whitebar}[1]{\@set[0](#1)}
  451. \newcommand{\blackbar}[1]{\@set[25](-#1)}
  452. \newcommand{\smallboard}{\def\@boardtype{@drawsmallboard}}
  453. \newcommand{\normalboard}{\def\@boardtype{@drawnormalboard}}
  454. \newcommand{\bigboard}{\def\@boardtype{@drawbigboard}}
  455. \newcommand{\boardcaption}[1]{\def\capt{#1}}
  456. \newcommand{\blackonmove}{\global\blacktrue}
  457. \newcommand{\whiteonmove}{\global\blackfalse}
  458. \newcommand{\dontshownumbers}{\global\numbersfalse}
  459. \newcommand{\shownumbers}{\global\numberstrue}
  460. \newcommand{\togglenumbers}{\ifptsonmove\global\ptsonmovefalse\else\ptsonmovetrue\fi}
  461. \newcommand{\dontshowcube}{\global\cubefalse}
  462. \newcommand{\showcube}{\global\cubetrue}
  463. \newcommand{\blackcube}[1]{\gdef\cubeowner{\@black}\edef\@cubevalue{#1}}
  464. \newcommand{\whitecube}[1]{\gdef\cubeowner{\@white}\edef\@cubevalue{#1}}
  465. \newcommand{\middlecube}[1]{\gdef\cubeowner{\@middle}\edef\@cubevalue{#1}}
  466. \newcommand{\showmoves}{\global\movestrue}
  467. \newcommand{\dontshowmoves}{\global\movesfalse}
  468. \newcommand{\indentwhite}{\global\indenttrue}
  469. \newcommand{\dontindentwhite}{\global\indentfalse}
  470. \newcommand{\halfboard}{\global\bothhalfsfalse}
  471. \newcommand{\fullboard}{\global\bothhalfstrue}
  472. \newcommand{\halfincr}{\global\secmovetrue}
  473. \newcommand{\fullincr}{\global\secmovefalse}
  474. \newcommand{\printboard}{\par\vspace{2em}
  475. \centerline{\csname \@boardtype \endcsname}\par
  476. \vspace{0.5em}
  477. \centerline{\capt}
  478. \vspace*{1.5em}\par}
  479. \newcommand{\rawboard}{\mbox{\csname\@boardtype\endcsname}}
  480. \def\dices(#1#2){\@value=#1\multiply\@value by 10\advance\@value by #2\relax
  481. \the\@value}
  482. \newcommand{\move}[2]{\gdef\comma{}\gdef\stringofmoves{}\relax\expandafter\@moveallcheckers#2,69-69,69-69.
  483. \ifmoves
  484. \par\ifindent\ifblack\else\hspace*{\@whiteskip}\fi\fi
  485. \ifsecmove
  486. \@value=\@movenumber\advance\@value by 1\divide\@value 2
  487. \else
  488. \@value=\@movenumber
  489. \fi
  490. \the\@value. \ifblack$\bullet$ \else$\circ$ \fi
  491. \dices(#1)
  492. : \stringofmoves\par
  493. \fi
  494. \ifblack\global\blackfalse\else\blacktrue\fi
  495. \advance \@movenumber by 1}
  496. \newcommand{\textmove}[1]{\ifmoves
  497. \par\ifblack\else\ifindent\hspace*{\@whiteskip}\fi\fi
  498. \ifsecmove
  499. \@value=\@movenumber\advance\@value by 1\divide\@value 2
  500. \else
  501. \@value=\@movenumber
  502. \fi
  503. \the\@value. \ifblack$\bullet$ \else$\circ$ \fi#1\par
  504. \fi
  505. \ifblack\global\blackfalse\else\blacktrue\fi
  506. \advance \@movenumber by 1}
  507. \newcommand{\takecube}{\ifblack\gdef\cubeowner{\@white}\else\gdef\cubeowner{\@black}\fi
  508. \@value=\@cubevalue\multiply\@value by 2\edef\@cubevalue{\the\@value}}
  509.  
  510.  
  511. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  512. % The position environment to produce a single board %
  513. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  514.  
  515. \newenvironment{position}%
  516. {\@clearboard
  517. \gdef\capt{}
  518. \gdef\cubeowner{\@middle}
  519. \gdef\@cubevalue{1}
  520. }%
  521. {\printboard}
  522.  
  523. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  524. % The game environment to annotate matches %
  525. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  526.  
  527. \newenvironment{game}[2]%
  528. {\initboard
  529. \gdef\capt{}
  530. \global\blacktrue
  531. \gdef\cubeowner{\@middle}
  532. \gdef\@cubevalue{1}
  533. \global\@movenumber=1
  534. \ifx\@empty#1\else\ifx\@empty#2\else
  535. \ifindent
  536. \par\hbox{\large\hbox to \@whiteskip{$\bullet$ #1\hfill}\hbox{$\circ$ #2}}\par
  537. \else
  538. \par\vbox{\large\hbox{$\bullet$ #1\hfill}\hbox{$\circ$ #2}}\par
  539. \fi
  540. \vspace*{4ex}
  541. \fi\fi
  542. }%
  543. {}
  544.